<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport"
              content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <title>首页</title>
    </head>
    <body>
    <!--匿名-->
        <div sec:authorize = "isAnonymous()">
            未登陆，点击<a th:href="@{/login}">登陆</a>
        </div>
        <div sec:authorize="isAuthenticated()">
            <p>已经登陆</p>
            <p>登陆名：<span sec:authentication="name"></span></p>
            <p>角色: <span sec:authentication="principal.authorities"></span></p>
            <p>Username: <span sec:authentication="principal.username"></span></p>
            <p>Password: <span sec:authentication="principal.password"></span></p>
            <p>Email: <span sec:authentication="principal.email"></span></p>
            <p>Name: <span sec:authentication="principal.name"></span></p>
            <p>Status: <span sec:authentication="principal.status"></span></p>
            <p>拥有的角色:
                <span sec:authorize="hasRole(ROLE_ADMIN)">管理员</span>
                <span sec:authorize="hasRole(ROLE_USER)">用户</span>
            </p>
        </div>
    </body>
</html>